package com.gitee.wsl.compose.state.ext

import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberUpdatedState
import com.gitee.wsl.compose.state.S


/**
 * @Composable
 * fun DelayOutputText(
 *     text: String,
 * ) {
 *
 *     val rememberText: State<String> = rememberUpdatedState(newValue = text)
 *     var delayOutputText by remember { mutableStateOf("") }
 *     LaunchedEffect(Unit) {
 *         delay(3000L)
 *
 *         delayOutputText = rememberText.value
 *     }
 *     Text("延迟输出的值：$delayOutputText")
 * }
 */
//旧值问题
@Composable
fun <T> S.useLatestState(init:T) = rememberUpdatedState(init)